package com.achievement.controller;

import com.achievement.domain.dto.honor.ReviewResultDTO;
import com.achievement.domain.param.honor.ReviewResultParam;
import com.achievement.domain.vo.honor.ReviewResultVO;
import com.achievement.service.IReviewResultService;
import com.common.annotation.Anonymous;
import com.common.annotation.Log;
import com.common.core.controller.BaseController;
import com.common.core.domain.AjaxResult;
import com.common.core.page.TableDataInfo;
import com.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "成果管理-获奖评审-评审结果")
@RestController
@RequestMapping("/achievement/reviewResult")
public class ReviewResultController extends BaseController {
        @Autowired
        private IReviewResultService ReviewResultService;
        @PreAuthorize("@ss.hasPermi('achievement:reviewResult:list')")
        @ApiOperation("获取评审结果列表")
        @GetMapping("/list")
        public TableDataInfo list(ReviewResultParam param)
        {
            startPage();
            List<ReviewResultVO> list = ReviewResultService.selectByPage(param);
            return getDataTable(list);
        }


        /**
         * 获取评审结果详细信息
         */
        @PreAuthorize("@ss.hasPermi('achievement:reviewResult:query')")
        @ApiOperation("获取评审结果详情")
        @GetMapping(value = "/{id}")
        public AjaxResult getInfo(@PathVariable("id") String id)
        {
            return success(ReviewResultService.getInfoById(id));
        }

        /**
         * 新增评审结果
         */
        @PreAuthorize("@ss.hasPermi('achievement:reviewResult:add')")
        @ApiOperation("新增评审结果")
        @Log(title = "新增评审结果", businessType = BusinessType.INSERT)
        @PostMapping(value = "/add")
        public AjaxResult add(@RequestBody ReviewResultDTO dto)
        {
            return toAjax(ReviewResultService.add(dto));
        }

        /**
         * 修改评审结果
         */
        @ApiOperation("修改评审结果")
        @Log(title = "修改评审结果", businessType = BusinessType.UPDATE)
        @PutMapping(value = "/update")
        public AjaxResult edit(@RequestBody ReviewResultDTO dto)
        {
            return toAjax(ReviewResultService.update(dto));
        }

        /**
         * 删除评审结果
         */
        @PreAuthorize("@ss.hasPermi('achievement:reviewResult:remove')")
        @ApiOperation("删除评审结果")
        @Log(title = "删除评审结果", businessType = BusinessType.DELETE)
        @DeleteMapping("/del/{ids}")
        public AjaxResult remove(@PathVariable List<String> ids)
        {
            return toAjax(ReviewResultService.batchRemove(ids));
        }
}
